package com.itheima.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.itheima.dao.MemberDao;
import com.itheima.dao.OrderDao;
import com.itheima.service.WorkBenchService;
import com.itheima.util.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.Map;

@Service(interfaceClass =WorkBenchService.class )
public class WorkBenchServiceImpl  implements WorkBenchService {

    @Autowired
    private OrderDao orderDao;

    @Autowired
    private MemberDao memberDao;

    /*
     * (工作台)VUE对象初始化完成后,查询数据
     * */
    @Override
    public Map<String, Object> getMessage() throws Exception {

        //获取今天日期
        String today = DateUtils.parseDate2String(DateUtils.getToday());

        // todayOrderNumber:0,/*今日预约人数*/
        Integer todayOrderNumber=orderDao.findOrderCountByDate(today);

        // totalOrderNumber:0,/*预约总人数*/
        Integer totalOrderNumber=orderDao.findOrderCount();

        //  todayNewMember:0,/*今日新增会员*/
        Integer todayNewMember=memberDao.findMemberCountByDate(today);

        // totalMember:0,/*会员总数*/
        Integer totalMember=memberDao.findMemberTotalCount();

        //封装数据
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("todayOrderNumber",todayOrderNumber);
        map.put("totalOrderNumber",totalOrderNumber);
        map.put("todayNewMember",todayNewMember);
        map.put("totalMember",totalMember);


        return map;
    }
}
